package com.gitee.candy.configer.aspect;

import com.gitee.candy.configer.interceptor.HandlingTimeInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>
 * 根据logging.enable的值（默认为true）将HandlingTimeInterceptor拦截器添加到SpringMVC容器中
 *
 * @author ：suyanlong
 * @date ：Created in 2020/11/11 16:39
 * @description：
 * @version: 1.0
 */
@Configuration
@ConditionalOnProperty(prefix = "logging", name = "enable",
        havingValue = "true", matchIfMissing = true)
public class WebConfiguration implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //多个拦截器会按照顺序进行校验拦截  内部维护了一个list集合 registrations
        registry.addInterceptor(new HandlingTimeInterceptor());
    }
}
